package com.gobo.jinghuimall.orders.vo;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;

public class SettleVo {
    /**
     * 用户信息
     */
    @Getter
    @Setter
    private List<RecInfo> addressList;
    /**
     * 购物车商品信息
     */
    @Getter
    @Setter
    private List<CartItemVo> items;
    /**
     * 积分
     */
    @Getter
    @Setter
    private Integer integral;
    /**
     * 应付价格
     */
    private BigDecimal payPrice;

    public BigDecimal getPayPrice() {
        BigDecimal allPrice = getTotalPrice();
        return allPrice;
    }

    /**
     * 总价
     */
    private BigDecimal totalPrice;

    public BigDecimal getTotalPrice() {
        BigDecimal allPrice = new BigDecimal("0");
        if (items != null) {
            for (CartItemVo item : items) {
                BigDecimal totalPrice = item.getTotalPrice();
                if (totalPrice != null) {
                    allPrice = allPrice.add(totalPrice);
                }
            }
        }
        return allPrice;
    }

    private Integer count;

    public Integer getCount() {
        int totalCount = 0;
        if (items != null) {
            for (CartItemVo item : items) {
                Integer count = item.getCount();
                if (count != null) {
                    totalCount += count;
                }
            }
        }
        return totalCount;
    }

    /**
     * 防重令牌
     */
    @Getter
    @Setter
    private String orderToken;
}
